import React, { Dispatch } from 'react';
import { AssetDisposeManageAPI } from '../common/type';

interface AsssetDisponseTableTypes {
  dataSource: Record<string, any>[]; //表格数据
  loading: boolean; // 加载
  mapList: Record<string, any>;
  pagination: Record<string, any>; //分页参数
  otherParams: Record<string, any>; //当前请求参数
  searchList: AssetDisposeManageAPI.ISearchList;
  reloadTableData: () => void; // 重置
  [key: string]: any;
}

/**
 * Context 默认值类型
 */
type ManageContextTypes = {
  rightTableProps: AsssetDisponseTableTypes; //表格数据参数
  curRes: Record<string, any>; // 权限
  assetDisponseDispatch: Dispatch<any>; // 派发
};

/**
 * useContext
 * @rightTableProps 公共表格所需参数
 * @curRes 权限
 * @assetDisponseDispatch reduce 派发器
 */
const INIT_ASSETDISPONSEMANAGE_CONTEXT: ManageContextTypes = {
  rightTableProps: {
    dataSource: [
      {
        id: '100000000151',
        time: '2023-12',
        store: '北京市怀柔区怀柔实验室仓库',
        company: '怀柔实验室',
        bumen: '',
        price: 2000,
        addPrice: 1000,
        count: '15000',
        assetType: '土地',
      },
      {
        id: '100000000152',
        time: '2023-10',
        store: '北京市怀柔区怀柔实验室仓库',
        company: '山西基地',
        bumen: '山西研究院',
        price: 10,
        addPrice: 5000,
        count: '5000',
        assetType: '租赁土地',
      },
      {
        id: '100000000153',
        time: '2023-07',
        store: '北京市怀柔区怀柔实验室仓库',
        company: '山西基地',
        bumen: '科研管理处',
        price: 50,
        addPrice: 2000,
        count: '20000',
        assetType: '房屋',
      },
    ],
    loading: false,
    getAssetDisponseTableData: ({}) => {},
    mapList: [],
    pagination: {},
    otherParams: {},
    searchList: [],
    reloadTableData: () => {},
  },
  curRes: {},
  assetDisponseDispatch: () => {},
};

const AssetDisponseManageContext = React.createContext(INIT_ASSETDISPONSEMANAGE_CONTEXT);

export { AssetDisponseManageContext };
